<?php
class sfMatPhotoValidatedFile extends sfValidatedFile
{
  public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777)
  {
     //$this->path=sfConfig::get('sf_upload_dir')."/material/gallery";
    $file_name = parent::save($file, $fileMode, $create, $dirMode);

    //Обжим
    $this->generateThumbnail ( $file_name );
    $this->generateSmallThumbnail ( $file_name );
    /////
    
    return $file_name;
  }
  
public function generateThumbnail($value) 

	{
		@unlink($uploadDir . '/material/gallery/thumbnail/' . $value);
		$uploadDir = sfConfig::get ( 'sf_upload_dir' );
		$thumbnail = new sfThumbnail ( 120, 120 );
		$thumbnail->loadFile ( $uploadDir . '/material/gallery/' . $value );
		$thumbnail->save ( $uploadDir . '/material/gallery/thumbnail/' . $value );
	
	}
	
	public function generateSmallThumbnail($value) 

	{
		@unlink($uploadDir . '/material/gallery/_thumbnail/' . $value);
		$uploadDir = sfConfig::get ( 'sf_upload_dir' );
		$thumbnail = new sfThumbnail ( 50, 50 );
		$thumbnail->loadFile ( $uploadDir . '/material/gallery/' . $value );
		$thumbnail->save ( $uploadDir . '/material/gallery/_thumbnail/' . $value );
	
	}
	
}